<?php
namespace app\www\controller;
use think\Db;
class Index
{
    public function index()
    {

        // $sys = \app\common\model\Data::getSys();
        // $ext = \app\common\model\Data::getExt();

        // $d = [
        //     'sys'       => $sys, 
        //     'ext'       => $ext,
        // ];
        
        return view('');
    }



    public function about()
    {

       
        
        return view('');
    }


    public function team()
    {
        return view('');
    }


    public function contact()
    {
                
        return view('');
    }

    public function service()
    {

        
        
        return view('');
    }


    //直销之窗资讯
    public function news()
    {

            $page     = input('page');
            if(!$page)$page = '0';

            $sql = "
                select
                    [1]
                from
                    article
                where 
                    status = 0
                ";

            #分页
            $sql_count = str_replace("[1]", "count(*) as total", $sql);
            $total     = Db::query($sql_count);
            $total     = $total[0]['total'];
            $page_size   = 6;
            $page        = com_cur_page($total, $page,  $page_size);
            $page_data   = com_page_data($total, $page,  $page_size);
            


            #数据
            $start       = ($page - 1) * $page_size;
            $sql        .= " order by sort desc, id desc limit $start, $page_size";
            $field       = " id,title,pic,views,sort,status,create_time,description ";
            $sql_list    = str_replace("[1]", $field, $sql);
            $list        = Db::query($sql_list);

            $tol = ceil( $total / $page_size );

            for ($i=0; $i < $tol ; $i++) { 
                $sun[] = $i+1;
            }

            foreach ($list as $k => $v) {
                $list[$k]['year'] = date('Y', $v['create_time']);
                $list[$k]['day'] = date('m-d', $v['create_time']);
            }


            

            $data['list'] = $list;
            $data['max']  = $tol;   //总页数
            $data['page'] = $page;  //当前页
            $data['pagelist'] = $sun;  //页数

            // t($data);

        return view( '',$data );
    }



    public function showlist()
    {

        $id     = input('id');

        $date = Db::name('article')->where('id',$id)->find();

        return view('',$date);
    }


    public function skill1()
    {
        return view('');
    }
    public function skill2()
    {
        return view('');
    }
    public function skill3()
    {
        return view('');
    }
    public function skill4()
    {
        return view('');
    }
    public function skill5()
    {
        return view('');
    }



    



    
    //获取碎片，和系统配置
    public function demo(){
        $title = \app\common\model\Data::getSys("title");
        $index = \app\common\model\Data::getExt("index");
        
        t([$title,$index]);
    }
}











